home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / swingall.jar / javax / swing / plaf / basic / BasicTreeUI$ComponentHandler.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-07-15  |  1.7 KB  |  72 lines

  1. package javax.swing.plaf.basic;
  2.  
  3. import java.awt.Component;
  4. import java.awt.Container;
  5. import java.awt.event.ActionEvent;
  6. import java.awt.event.ActionListener;
  7. import java.awt.event.ComponentAdapter;
  8. import java.awt.event.ComponentEvent;
  9. import javax.swing.JScrollBar;
  10. import javax.swing.JScrollPane;
  11. import javax.swing.Timer;
  12.  
  13. public class BasicTreeUI$ComponentHandler extends ComponentAdapter implements ActionListener {
  14.    // $FF: synthetic field
  15.    private final BasicTreeUI this$0;
  16.    protected Timer timer;
  17.    protected JScrollBar scrollBar;
  18.  
  19.    public BasicTreeUI$ComponentHandler(BasicTreeUI var1) {
  20.       this.this$0 = var1;
  21.    }
  22.  
  23.    public void actionPerformed(ActionEvent var1) {
  24.       if (this.scrollBar == null || !this.scrollBar.getValueIsAdjusting()) {
  25.          if (this.timer != null) {
  26.             this.timer.stop();
  27.          }
  28.  
  29.          this.this$0.updateSize();
  30.          this.timer = null;
  31.          this.scrollBar = null;
  32.       }
  33.  
  34.    }
  35.  
  36.    public void componentMoved(ComponentEvent var1) {
  37.       if (this.timer == null) {
  38.          JScrollPane var2 = this.getScrollPane();
  39.          if (var2 == null) {
  40.             this.this$0.updateSize();
  41.          } else {
  42.             this.scrollBar = var2.getVerticalScrollBar();
  43.             if (this.scrollBar != null && this.scrollBar.getValueIsAdjusting()) {
  44.                this.startTimer();
  45.             } else if ((this.scrollBar = var2.getHorizontalScrollBar()) != null && this.scrollBar.getValueIsAdjusting()) {
  46.                this.startTimer();
  47.             } else {
  48.                this.this$0.updateSize();
  49.             }
  50.          }
  51.       }
  52.  
  53.    }
  54.  
  55.    protected JScrollPane getScrollPane() {
  56.       Container var1;
  57.       for(var1 = this.this$0.tree.getParent(); var1 != null && !(var1 instanceof JScrollPane); var1 = ((Component)var1).getParent()) {
  58.       }
  59.  
  60.       return var1 instanceof JScrollPane ? (JScrollPane)var1 : null;
  61.    }
  62.  
  63.    protected void startTimer() {
  64.       if (this.timer == null) {
  65.          this.timer = new Timer(200, this);
  66.          this.timer.setRepeats(true);
  67.       }
  68.  
  69.       this.timer.start();
  70.    }
  71. }
  72.